﻿using Microsoft.AspNetCore.Mvc;
using yunbo.Model.SM;
using yunbo.Repositorys.SMRepositorys;

namespace yunbo.Controllers.SMControllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class WMS_LLCKXXController : Controller
    {
        WMS_LLCKXXRepository _wms_llckxxRepository = new WMS_LLCKXXRepository();
        [HttpPost("Addllckxx")]
        public IActionResult Addllckxx(TJWMS_LLCKXX tJWMS_LLCKXX)
        {
            // 获取当前时间，并格式化为字符串
            string currentTime = DateTime.Now.ToString("yyyyMMdd");

            // 生成一个四位随机数
            Random random = new Random();
            int randomNumber = random.Next(1000, 10000); // 生成1000到9999之间的随机数
            string randomNumberString = randomNumber.ToString("D4"); // 格式化为四位数字字符串

            // 组合当前时间和随机数生成ID
            string id = $"ckxx{currentTime}{randomNumberString}";
            tJWMS_LLCKXX.llckxx_code = id;
            bool ll = _wms_llckxxRepository.AddllckXX(tJWMS_LLCKXX) > 0;
            return Ok(ll);
        }
        [HttpGet("Getckxx")]
        public IActionResult Getckxx(string code)
        {
            List<WMS_LLCKXX> wMS_LLCKXXes=_wms_llckxxRepository.GetWMS_LLCKXXes(code);
            return Ok(wMS_LLCKXXes);
        }
    }
}
